package com.newjiabo.web.controller.ski;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.newjiabo.common.annotation.Log;
import com.newjiabo.common.core.controller.BaseController;
import com.newjiabo.common.core.domain.AjaxResult;
import com.newjiabo.common.enums.BusinessType;
import com.newjiabo.ski.domain.SkiOrderShoot;
import com.newjiabo.ski.service.ISkiOrderShootService;
import com.newjiabo.common.utils.poi.ExcelUtil;
import com.newjiabo.common.core.page.TableDataInfo;

/**
 * 约拍订单Controller
 *
 * @author CaoMengHui
 * @date 2023-10-23
 */
@RestController
@RequestMapping("/ski/shoot")
public class SkiOrderShootController extends BaseController {

    @Autowired
    private ISkiOrderShootService skiOrderShootService;

    /**
     * 查询约拍订单列表
     */
    @PreAuthorize("@ss.hasPermi('ski:shoot:list')")
    @GetMapping("/list")
    public TableDataInfo list(SkiOrderShoot skiOrderShoot) {
        startPage();
        List<SkiOrderShoot> list = skiOrderShootService.selectSkiOrderShootList(skiOrderShoot);
        return getDataTable(list);
    }

    /**
     * 导出约拍订单列表
     */
    @PreAuthorize("@ss.hasPermi('ski:shoot:export')")
    @Log(title = "约拍订单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SkiOrderShoot skiOrderShoot) {
        List<SkiOrderShoot> list = skiOrderShootService.selectSkiOrderShootList(skiOrderShoot);
        ExcelUtil<SkiOrderShoot> util = new ExcelUtil<SkiOrderShoot>(SkiOrderShoot.class);
        util.exportExcel(response, list, "约拍订单数据");
    }

    /**
     * 获取约拍订单详细信息
     */
    @PreAuthorize("@ss.hasPermi('ski:shoot:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return AjaxResult.success(skiOrderShootService.selectSkiOrderShootById(id));
    }

    /**
     * 新增约拍订单
     */
    @PreAuthorize("@ss.hasPermi('ski:shoot:add')")
    @Log(title = "约拍订单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SkiOrderShoot skiOrderShoot) {
        return toAjax(skiOrderShootService.insertSkiOrderShoot(skiOrderShoot));
    }

    /**
     * 修改约拍订单
     */
    @PreAuthorize("@ss.hasPermi('ski:shoot:edit')")
    @Log(title = "约拍订单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SkiOrderShoot skiOrderShoot) {
        return toAjax(skiOrderShootService.updateSkiOrderShoot(skiOrderShoot));
    }

    /**
     * 删除约拍订单
     */
    @PreAuthorize("@ss.hasPermi('ski:shoot:remove')")
    @Log(title = "约拍订单", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(skiOrderShootService.deleteSkiOrderShootByIds(ids));
    }
}
